package com.yy.finvideoplayer.media

import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import tv.danmaku.ijk.media.player.IMediaPlayer


/**
 * @Description: IjkExoMedia
 * @Author: yiw89
 * @CreateDate: 2025/9/1 14:05
 * @Version: 1.0
 */
class IjkExoMedia(iMediaCallback: IMediaCallback) :
    IjkBaseMedia(iMediaCallback) {
    @Throws(Exception::class)
    override fun getMedia(
        context: Context,
        url: String,
        headers: Map<String, String?>?,
        vararg objects: Any?
    ): IMediaPlayer? {

        /*val mediaPlayer = IjkExoMediaPlayer(context)

        if (url.startsWith(ContentResolver.SCHEME_FILE)) {
            mediaPlayer.setDataSource(url.replace("file:/", ""))
            //mediaPlayer.dataSource = url.replace("file:/", "")
        } else {
            mediaPlayer.setDataSource(context, Uri.parse(url))
        }

        mainThreadHandler.postDelayed(runnable, 500)
        return mediaPlayer*/
        return null
    }

    private var runnable: Runnable = object : Runnable {
        override fun run() {
            /*if (isPrepar) onBufferingUpdate(
                mediaPlayer,
                (mediaPlayer as IjkExoMediaPlayer).bufferedPercentage
            )
            mainThreadHandler.postDelayed(this, 1000)*/
        }
    }


    override fun setSpeed(rate: Float): Boolean {



        return false
    }

    override fun release() {
        super.release()
        mainThreadHandler.removeCallbacks(runnable)
    }
}